package kr.hkit.powerjava.algorithm;

public class Queue implements Structure {

	private int size;
	private int r;
	private int f;
	private String[] arrQue;

	public Queue(int size) {
		this.size = size;
		arrQue = new String[size];
		r = -1;
		f = -1;
	}

	@Override
	public void push(String item) {
		if (!isFull()) {
			arrQue[++r] = item;
		} else {
			System.out.println("Queue is Full");
		}
	}

	@Override
	public String pop() {
		if (!isEmpty()) {
			return arrQue[++f];
		} else {
			return "Queue is Empty";
		}
	}

	@Override
	public boolean isFull() { 
		return r == size;
	}

	@Override
	public boolean isEmpty() {
		return r == -1;
	}

	@Override
	public void prn() {
		for (int i = 0; i <= r; i++) {
			System.out.printf("[%s", arrQue[i] + "] ");
		}
		System.out.println();
	}

	public void prn2() {
		for (int i = f+1 ; i <=r ; i++) {
			System.out.printf("[%s", arrQue[i]+ "] ");
		}
		System.out.println();
	}
	
}
